<template>
    <div class="detail">
        <h2 class="title">{{descData.title}}</h2>
        <img width="700" :src="descData.imgUrl">
        <div class="detail-info" v-for="(item,index) in descData.desc"
        :key="index">
            <p>{{ item }}</p>
        </div>
    </div>
</template>

<script>
    import axios from "axios";
    export default {
        data() {
            return {
                goodId: 0,
                detailData: [],
                descData: {}
            };
        },
        methods: {
            getDetail() {
                axios.get("../../static/api/home.json").then(res => {
                    this.detailData = res.data.data.detail;
                    this.detailData.forEach((item, index) => {
                        if (item.id == this.goodId) {
                            this.descData = item;
                        }
                    });
                });
            }
        },
        mounted() {
            this.goodId = this.$route.params.goodId;
            this.getDetail();
        }
    };
</script>

<style scoped>
.detail {
    margin: 0 auto;
    padding-top: 20px;
    padding-bottom: 40px;
    width: 720px;
}
.title {
    word-break: break-word !important;
    word-break: break-all;
    margin: 20px 0 20px;
    font-size: 34px;
    font-weight: 700;
    line-height: 1.3;
}
.detail-info p {
    font-size: 16px;
    font-weight: 400;
    line-height: 1.7;
    color: #2f2f2f;
    margin: 0 0 15px;
    text-indent: 2em;
}
</style>